<?php
@header("Content-type: text/html; charset=utf-8");
require_once('../data/config.php');
require_once('../common/db.class.php');
require_once('../common/function.php');
require_once('../common/http_helper.php');
require_once('../common/weixin_helper.php');
require_once('../wall/biaoqing.php');
//$weixinconf = getWeixinConf();
$openid = $_GET['openid'];
$wall_config_m = new M('wall_config');
$wall_config = $wall_config_m->find('1', '*', '');
$flag_m = new M('flag');
$weixininfo = $flag_m->find('openid="' . $openid . '"');
$weixininfo['nickname'] = pack('H*', $weixininfo['nickname']);
$weixininfo = emoji_unified_to_html(emoji_softbank_to_unified($weixininfo));
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>欢迎进入微现场签到活动</title>
    <link rel="stylesheet" href="css/qiandao/style.css" type="text/css">
    <link rel="stylesheet" href="css/qiandao/semantic.min.css" type="text/css">
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <style>
        #toast {
            display: none;
            position: fixed;
            padding: 9px 15px;
            background-color: #333;
            z-index: 8000;
            border-radius: 5px;
            font-size: 15px;
            color: #ffffff;
            line-height: 25px;
            text-align: center;
        }

        .sign_des {
            display: inline-block;
            width: 60%;
            line-height: 40px;
            height: 40px;
        }
    </style>
</head>
<body id='vote'>
<div class="main container">
    <div class="ui page grid">
        <div class="column">
            <h4 class="ui attached green segment votehead" style="text-align:Center">
                欢迎进入微现场签到活动 </h4>

            <div class="ui attached segment content">
                <div class="image" style="text-align:center;">
                    <img
                        src="<?php echo $weixininfo['avatar']; ?>"
                        style="width:120px;height:120px;border-radius:100%">
                </div>
                <div style="height:40px;line-height:40px;text-align:center">
                    <a class="header"><?php echo $weixininfo['nickname']; ?></a>
                </div>
                <?php if($wall_config['name_switch']==1){ ?>
                <div style="height:40px;line-height:40px;text-align:center">
                    <a class="header">姓名：<?php echo $weixininfo['signname']; ?></a>
                </div>
                <?php  }?>
                <?php if($wall_config['phone_switch']==1){ ?>
                <div style="height:40px;line-height:40px;text-align:center">
                    <a class="header">手机号：<?php echo $weixininfo['phone']; ?></a>
                </div>
                <?php  }?>
                <div style="width:100%;text-align:center;border-radius:5px;">
                    <div style="width:100%;text-align:center;border-radius:5px;background:#F7F2F2;">
                        <div class="content sign_des" style="">您是第<font
                                color=pink><?php echo $weixininfo['id']; ?></font>位签到用户
                        </div>
                        <div class="content sign_des"
                             style="border-top:1px solid gray;font-size:12px;"><?php echo date('Y-m-d H:i:s',$weixininfo['datetime']); ?></div>
                    </div>
                </div>
                <div style="width:100%;text-align:center;border-radius:5px;">
                    签到成功！返回发送消息就可以参与互动了哟！
                    <div style="height:40px;line-height:40px;text-align:center;margin-bottom:20px">
                        <div class="content" id="closewindow" style="display:inline-block;width:60%;background:pink;border-radius:5px;">
                            关闭本页面
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <small class="footer">
        <center>
            <?php 
            require '../common/settings.php';
             ?>
            <a href="<?php echo $settings['companyurl'];?>"><?php echo $settings['company'];?></a></center>
    </small>
</div>
<div id="toast"></div>
<script type="text/javascript">
    $(function () {
        $('#closewindow').on("click", function () {
            WeixinJSBridge.invoke('closeWindow', {});
        });
    });
    $('#submit').on('click', function () {
        var sign_words = $('#sign_words').val();
        if ("undefined" == typeof sign_words || sign_words == '') {
            _loading_toast._show('请输入签到祝福语！');
            $('#sign_words').focus();
            return;
        }
        $.ajax({
            type: "POST",
            url: "./index.php?i=38&c=entry&rid=1093&do=qd_post&m=meepo_bigerwall",
            data: {'sign_words': sign_words},
            dataType: "json",
            success: function (data) {

                _loading_toast._show(data.message);
                if (data.errno == '0') {
                    setTimeout('refresh()', 2 * 1000);

                }
            }
        });

    })
    function refresh() {
        window.location.href = "./index.php?i=38&c=entry&rid=1093&do=qd&m=meepo_bigerwall&t=" + new Date().getTime();
    }
    var _loading_toast = {
        _center: function () {
            var _left = ($(window).width() - $("#toast").outerWidth()) / 2 + "px";
            $("#toast").css({
                "top": "50%",
                "left": _left
            });
        },
        _show: function (text, fun) {
            $("#toast").html(text);
            _loading_toast._center();
            $("#toast").show();
            $("#toast").bind("resize", _loading_toast._center);
            setTimeout(function () {
                _loading_toast._hide(fun);
            }, 3 * 1000);
        },
        _hide: function (fun) {
            $("#toast").hide();
            $("#toast").unbind("resize");
            if (fun) {
                (fun)();
            }
        }
    };
</script>
<script>var imgs = document.getElementsByTagName('img');
    for (var i = 0, len = imgs.length; i < len; i++) {
        imgs[i].onerror = function () {
            if (!this.getAttribute('check-src') && (this.src.indexOf('http://') > -1 || this.src.indexOf('https://') > -1)) {
                this.src = this.src.indexOf('http://www.passboat.cn/attachment/') == -1 ? this.src.replace('http://passboat.oss-cn-shanghai.aliyuncs.com/', 'http://www.passboat.cn/attachment/') : this.src.replace('http://www.passboat.cn/attachment/', 'http://passboat.oss-cn-shanghai.aliyuncs.com/');
                this.setAttribute('check-src', true);
            }
        }
    }</script>
</body>
</html>